﻿#pragma once

#include "Math/Vec3.h"
#include "Math/Color.h"
#include "Math/Quat.h"
#include "Math/Matrix4x4.h"

#include "Render/Mesh/RenderMesh.h"
#include "Render/Material/RenderMaterial.h"

class CPreRenderMesh;
class CPreRenderMaterial;

struct SPreRenderPointLight
{
    SVec3 Position;   //光源位置
    SColor Color;     //光颜色
    float Intensity;  //光强度
    float Radius;     //光照半径
    float ShadowBias; //阴影偏移
};


struct SPreRenderSpotLight
{
    SVec3 Position;
    SQuat Rotation;

    SColor Color;
    float Intensity;
    float Radius;
    float ConeAngle;
    float ShadowBias;
};


//直射光所需的所有参数
struct SPreRenderDirectionalLight
{
    SQuat Rotation;

    SColor Color;
    float Intensity;

    //光源到被照射物体的距离
    float MaxCastShadowDistance=1000.f;

    //每一级的阴影图距离相机近平面的距离
    TVector<float> CascadeMaxDepths={ 20.f,40.f,80.f,100.f };

    //阴影偏移(0,1)
    float ShadowBias=0.001f;
};


struct SPreRenderMeshInstance
{
    SVec3 Position;
    SQuat Rotation;
    SVec3 Scale;

    //包围球半径,用于快速剔除
    //这个半径需要缩放
    float BoundingSphereRadius;

    TVector<std::shared_ptr<CPreRenderMesh>> MeshSections;
    TVector<std::shared_ptr<CPreRenderMaterial>> Materials;
    bool CastShadow = true;

    SMatrix4x4 GetModelMatrix() const
    {
        return SMatrix4x4(Position, Rotation, Scale);
    }

};

